Spreadsheet II

Spreadsheet I showed how you could use the onChange property to stimulate recalculation of a spreadsheet-like form, although you'd have to re-program the script to change how the spreadsheet calculated cell results. This recipe goes one step further to create a full-fledged programmable spreadsheet. Enter formulas starting with an equals sign ('='). Reference cells by column first, i.e. "A5".

Formula View:

Discussion

This version of the spreadsheet is a tribute to what can be done with the JavaScript eval() function. The script looks at each cell formula, and decides which symbols are cell references and which are numbers (or intrinsic functions--see below). When it finds a cell reference it gets the value of the cell and substitutes it into the formula, and finally submits the whole expanded string to eval() for analysis.

Like the first spreadsheet, this one is sized by the use of the sheetHeight and sheetWidth JavaScript variables which are programmed into this document.

You can enter formulas and numbers right into the cells; precede formulas with an equals sign ('='). To view a cell's formula, click in the cell and the formula will appear in the view bar at the top (you can use cut and paste editing to change the formula and put it back in the cell). Use <Tab> to move between cells and complete editing rather than <Enter>.

Details

There are several rules to remember when using this spreadsheet:

Just in case you try to use this to do your taxes:

Use at your own risk. No warranty is given or implied of the suitability
of this spreadsheet applet for any specific application. Neither the authors
nor the publisher will be held responsible for any unwanted effects due to the
use of this applet or any derivative.


Copyright ©1998 by Charles River Media, All Rights Reserved